home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / SIMPLE.PAK / SIMPLE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  2.5 KB  |  94 lines

  1. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  2. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  3. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  4. // PARTICULAR PURPOSE.
  5. //
  6. // Copyright (C) 1993-1995  Microsoft Corporation.  All Rights Reserved.
  7. //
  8. //  MODULE:   simple.c
  9. //
  10. //  PURPOSE:   Implement the windows procedure for the main application
  11. //    windows.
  12. //
  13. //  FUNCTIONS:
  14. //    WndProc - Processes messages for the main window.
  15. //
  16. //  COMMENTS:
  17. //
  18.  
  19. #include <windows.h>            // required for all Windows applications
  20. #include <windowsx.h>
  21. #ifdef WIN16
  22. #include "win16ext.h"           // required only for win16 applications
  23. #endif
  24. #include "globals.h"            // prototypes specific to this application
  25. #include "resource.h"
  26.  
  27. //
  28. //  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
  29. //
  30. //  PURPOSE:  Processes messages
  31. //
  32. //  PARAMETERS:
  33. //    hwnd     - window handle
  34. //    uMessage - message number
  35. //    wparam   - additional information (dependant of message number)
  36. //    lparam   - additional information (dependant of message number)
  37. //
  38. //  MESSAGES:
  39. //
  40. //    WM_COMMAND    - exit command
  41. //    WM_DESTROY    - destroy window
  42. //
  43. //  RETURN VALUE:
  44. //
  45. //    Depends on the message number.
  46. //
  47. //  COMMENTS:
  48. //
  49. //
  50.  
  51. LRESULT CALLBACK WndProc(HWND hwnd,
  52.                          UINT uMessage,
  53.                          WPARAM wparam,
  54.                          LPARAM lparam)
  55. {
  56.     switch (uMessage)
  57.     {
  58.  
  59.         //
  60.         // **TODO** Add cases here for application messages
  61.         //
  62.  
  63.         case WM_COMMAND: // message: command from application menu
  64.  
  65.             // Message packing of wparam and lparam have changed for Win32,
  66.             // so use the GET_WM_COMMAND macro to unpack the commnad
  67.  
  68.             switch (GET_WM_COMMAND_ID(wparam,lparam))
  69.             {
  70.  
  71.                 //
  72.                 // **TODO** Add cases here for application specific commands
  73.                 //
  74.  
  75.                 case IDM_EXIT:
  76.                     DestroyWindow(hwnd);
  77.                     break;
  78.  
  79.  
  80.                 default:
  81.                     return DefWindowProc(hwnd, uMessage, wparam, lparam);
  82.             }
  83.             break;
  84.  
  85.         case WM_DESTROY:  // message: window being destroyed
  86.             PostQuitMessage(0);
  87.             break;
  88.  
  89.         default:          // Passes it on if unproccessed
  90.             return DefWindowProc(hwnd, uMessage, wparam, lparam);
  91.     }
  92.     return 0;
  93. }
  94.